<?php
/**
 * Created by PhpStorm.
 * User: fyl
 * Date: 2016/8/13
 * Time: 11:06
 */

class Involved_BrandModel extends BaseModel{

    protected $table = 'brand';

    /**
     * 获取品名列表
     * @author fyl
     * @date 2016-08-13
     */
    public function AdminProductBrandList()
    {
        return DB::table($this->table)
            ->select('brand_id','brand_name','cate_id')
            ->get();
    }

    /**
     * 根据ID获取产品详情
     * @return mixed
     */
    public function GetProductBrandById1($id)
    {
        return  DB::table($this->table)
            ->where('brand_id',$id)
            ->first();
    }

    /**
     * 获取品名下拉菜单
     * @author fyl
     * @date 2016-08-13
     */
    public function SelectBrand()
    {
        return DB::table($this->table)
            ->select('brand.brand_id','brand.brand_name','brand.cate_id','category_spec.category_name')
            ->leftjoin('category_spec','brand.cate_id','=','category_spec.id')
            ->get();
    }

    /**
     * 获取品名下拉菜单
     * @author fyl
     * @date 2016-08-13
     */
    public function SelectBrandCategory($category)
    {
        return DB::table($this->table)
            ->select('brand.brand_id','brand.brand_name','brand.cate_id','category_spec.category_name')
            ->leftjoin('category_spec','brand.cate_id','=','category_spec.id')
            ->where('category_name',$category)
            ->get();
    }


    /**
     * 品名是否存在
     * @param $brand_name
     * @return mixed
     */
    public function ProductBrandIs($brand_name)
    {
        return DB::table($this->table)
            ->select('brand_id')
            ->where('brand_name',$brand_name)
            ->first();
    }
}